package com.wf.ew.daily.service.impl;

import com.wf.ew.common.JsonResult;
import com.wf.ew.common.PageResult;
import com.wf.ew.system.model.User;
import com.wf.ew.daily.biz.ScheduleBiz;
import com.wf.ew.daily.model.Schedule;
import com.wf.ew.daily.service.ScheduleService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;

/**
 *
 * 数据服务层接口实现类
 * @author : Doman
 * @date : 2020-01-05 11:22:55
 * @version ：1.0
 */
@Service
public class ScheduleServiceImpl implements ScheduleService {

	@Autowired
	private ScheduleBiz scheduleBiz;

	@Override
	public String list(PageResult<T> page, Schedule schedule, User loginUser) {
		return scheduleBiz.list(page,schedule,loginUser);
	}
	
	@Override
	public List<Schedule> list(Schedule schedule, User loginUser) {
		return scheduleBiz.list(schedule,loginUser);
	}

	@Override
	public Schedule getById(Schedule schedule) {
		return scheduleBiz.getById(schedule);
	}

	@Transactional
	@Override
	public JsonResult add(Schedule schedule, User loginUser) {
		if (scheduleBiz.add(schedule, loginUser)) {
			return JsonResult.ok("添加成功");
		}
		return JsonResult.error("添加失败");
	}

	@Transactional
	@Override
	public JsonResult update(Schedule schedule, User loginUser) {
		if (scheduleBiz.update(schedule, loginUser)) {
			return JsonResult.ok("修改成功");
		}
		return JsonResult.error("修改失败");
	}

	@Transactional
	@Override
	public JsonResult delete(Schedule schedule, User loginUser) {
		if (scheduleBiz.delete(schedule, loginUser)) {
			return JsonResult.ok("删除成功");
		}
		return JsonResult.error("删除失败");
	}
}
